package com.sgb.net.entity;

import com.google.gson.annotations.SerializedName;

/**
 * @author: 杨畔
 * @date: 2021/2/19 14:56
 * @Description: 数据基类
 */
public class BaseEntity<D> implements EntityInterface<D> {
    private Integer code;
    private String msg;
    @SerializedName(value = "data", alternate = {"result", "records"})
    private D data;
    @SerializedName(value = "state", alternate = {"status"})
    private String state;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public D getData() {
        return data;
    }

    public void setData(D data) {
        this.data = data;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    @Override
    public Integer code() {
        return code;
    }

    @Override
    public String msg() {
        return msg;
    }

    @Override
    public D data() {
        return data;
    }

    @Override
    public boolean isSuccess() {
        //todo 待确认
        return SUCCESS.equals(state);
    }
}
